﻿<?xml version="1.0" encoding="utf-8" ?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:buildinator.tfsbuilds">
	<xs:element name="BuildDefs">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="TFSBuild" maxOccurs="unbounded">
					<xs:complexType mixed="true">
						<xs:sequence>
							<xs:element name="Description" type="xs:string" minOccurs="0" maxOccurs="1" />

							<xs:element name="Trigger" minOccurs="1" maxOccurs="1">
								<xs:complexType>
									<xs:sequence>
										<xs:element name="Schedule" minOccurs="0" maxOccurs="1">
											<xs:complexType>
												<xs:sequence>
													<xs:element name="Day" maxOccurs="unbounded">
														<xs:simpleType>
															<xs:restriction base="xs:string">
																<xs:enumeration value="Sunday" />
																<xs:enumeration value="Monday" />
																<xs:enumeration value="Tuesday" />
																<xs:enumeration value="Wednesday" />
																<xs:enumeration value="Thursday" />
																<xs:enumeration value="Friday" />
																<xs:enumeration value="Saturday" />
															</xs:restriction>
														</xs:simpleType>
													</xs:element>
												</xs:sequence>
												<xs:attribute name="StartTime" type="xs:string" use="required" />
												<xs:attribute name="TimeZone" type="xs:string" use="required" />
												<xs:attribute name="BuildRegardlessOfChanges" type="xs:boolean" use="optional" />
											</xs:complexType>
										</xs:element>
									</xs:sequence>
									<xs:attribute name="Type" use="required">
										<xs:simpleType>
											<xs:restriction base="xs:string">
												<xs:enumeration value="None" /> <!-- Manual: No trigger -->
												<xs:enumeration value="Individual" /> <!-- Continuous Integration - Each Check-in -->
												<xs:enumeration value="Batch" /> <!-- Rolling builds -->
												<xs:enumeration value="Gated" /> <!-- Gated -->
												<xs:enumeration value="Schedule" /> <!-- Scheduled -->
											</xs:restriction>
										</xs:simpleType>
									</xs:attribute>
								</xs:complexType>
							</xs:element>

							<xs:element name="Map" minOccurs="1" maxOccurs="unbounded">
								<xs:complexType>
									<xs:attribute name="TFSPath" type="xs:string" use="required" />
									<xs:attribute name="Folder" type="xs:string" use="optional" />
								</xs:complexType>
							</xs:element>

							<xs:element name="Cloak" minOccurs="0" maxOccurs="unbounded">
								<xs:complexType>
									<xs:attribute name="TFSPath" type="xs:string" use="required" />
								</xs:complexType>
							</xs:element>

							<xs:element name="BuildControllerName" type="xs:string" minOccurs="1" maxOccurs="1" />
							<xs:element name="DropLocation" type="xs:string" minOccurs="1" maxOccurs="1" />
							<xs:element name="ProcessTemplate" type="xs:string" minOccurs="1" maxOccurs="1" />

							<xs:element name="Parameter" minOccurs="1" maxOccurs="unbounded">
								<xs:complexType>
									<xs:attribute name="Key" type="xs:string" use="required" />
									<xs:attribute name="Value" type="xs:string" use="required" />
								</xs:complexType>
							</xs:element>

							<xs:element name="AgentSettings" minOccurs="0" maxOccurs="1">
								<xs:complexType>
									<xs:attribute name="AgentNameFilter" type="xs:string" use="optional" />
									<xs:attribute name="MaxExecutionTime" type="xs:string" use="optional" />
									<xs:attribute name="MaxReservationTime" type="xs:string" use="optional" />
									<xs:attribute name="Tags" type="xs:string" use="optional" />
									<xs:attribute name="TagsFilter" use="optional">
										<xs:simpleType>
											<xs:restriction base="xs:string">
												<xs:enumeration value="MatchExactly" />
												<xs:enumeration value="MatchAtLeast" />
											</xs:restriction>
										</xs:simpleType>
									</xs:attribute>
								</xs:complexType>
							</xs:element>

							<xs:element name="RetentionPolicy" minOccurs="0" maxOccurs="1">
								<xs:complexType>
									<xs:sequence>
										<xs:element name="Policy" minOccurs="1" maxOccurs="unbounded">
											<xs:complexType>
												<xs:attribute name="BuildReason" use="required">
													<xs:simpleType>
														<xs:restriction base="xs:string">
															<xs:enumeration value="All" />
															<xs:enumeration value="BatchedCI" />
															<xs:enumeration value="CheckInShelveset" />
															<xs:enumeration value="IndividualCI" />
															<xs:enumeration value="Manual" />
															<xs:enumeration value="None" />
															<xs:enumeration value="Schedule" />
															<xs:enumeration value="ScheduleForced" />
															<xs:enumeration value="Triggered" />
															<xs:enumeration value="UserCreated" />
															<xs:enumeration value="ValidateShelveset" />
														</xs:restriction>
													</xs:simpleType>
												</xs:attribute>
												<xs:attribute name="BuildStatus" use="required">
													<xs:simpleType>
														<xs:restriction base="xs:string">
															<xs:enumeration value="All" />
															<xs:enumeration value="Failed" />
															<xs:enumeration value="InProgress" />
															<xs:enumeration value="None" />
															<xs:enumeration value="NotStarted" />
															<xs:enumeration value="PartiallySucceeded" />
															<xs:enumeration value="Stopped" />
															<xs:enumeration value="Succeeded" />
														</xs:restriction>
													</xs:simpleType>
												</xs:attribute>
												<xs:attribute name="Keep" type="xs:int" use="required" />
												<xs:attribute name="DeleteOptions" use="required">
													<xs:simpleType>
														<xs:restriction base="xs:string">
															<xs:enumeration value="All" />
															<xs:enumeration value="Details" />
															<xs:enumeration value="DropLocation" />
															<xs:enumeration value="Label" />
															<xs:enumeration value="None" />
															<xs:enumeration value="Symbols" />
															<xs:enumeration value="TestResults" />
														</xs:restriction>
													</xs:simpleType>
												</xs:attribute>
											</xs:complexType>
										</xs:element>
									</xs:sequence>
								</xs:complexType>
							</xs:element>

						</xs:sequence>
						<xs:attribute name="Name" type="xs:string" use="required" />
						<xs:attribute name="Enabled" type="xs:boolean" use="optional" />
					</xs:complexType>
				</xs:element>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>